#include<bits/stdc++.h>
using namespace std;

const int N = 505;
const int mod = 123456;
int dp[N][N];

int main() {
    int n, k;
    cin >> n >> k;
    dp[1][0] = 1;
    for (int i = 2; i <= n; i++) {
        dp[i][0] = 2;
        for (int j = 0; j <= i - 2; j++) {
            dp[i][j] %= mod;
            dp[i + 1][j] += dp[i][j] * (j + 1);
            dp[i + 1][j + 1] += dp[i][j] * 2;
            dp[i + 1][j + 2] += dp[i][j] * (i - j - 2); 
        }
    }

    cout << dp[n][k - 1] % mod << endl;
    return 0;
}